using System;
using System.Collections.Generic;
using System.Text;
using Utility;
using DAL;
using DTO;
namespace BUS
{
    public class tbDanhMucSanPhamBUS
    {
        public static void Insert(tbDanhMucSanPham dmsp)
        {
            tbDanhMucSanPhamDAL dmspDAL = new tbDanhMucSanPhamDAL();
            dmspDAL.Insert(dmsp);
        }
        public static void Update(tbDanhMucSanPham dmsp)
        {
            tbDanhMucSanPhamDAL dmspDAl = new tbDanhMucSanPhamDAL();
            dmspDAl.Update(dmsp);
        }
        public static void Delete(int iD)
        {
            tbDanhMucSanPhamDAL dmspDAl = new tbDanhMucSanPhamDAL();
            dmspDAl.Delete(iD);
        }
        public static tbDanhMucSanPhamCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            tbDanhMucSanPhamDAL dmspDAL = new tbDanhMucSanPhamDAL();
            return dmspDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbDanhMucSanPhamCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbDanhMucSanPhamDAL dmspDAL = new tbDanhMucSanPhamDAL();
            return dmspDAL.Get(cri.Criter, 0, 0, tbDanhMucSanPhamColumns.madanhmuc.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static tbDanhMucSanPham GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbDanhMucSanPhamColumns.madanhmuc.ToString(), Condition.EQUAL, iD);
            tbDanhMucSanPhamDAL dmspDAL = new tbDanhMucSanPhamDAL();
            tbDanhMucSanPhamCollection dmspCollection = dmspDAL.Get(cri.Criter, 0, 0, tbDanhMucSanPhamColumns.madanhmuc.ToString(), OrderDirection.ASC.ToString(), out total);
            if (dmspCollection.Count > 0)
                return dmspCollection[0];
            return null;
        }
        public static tbDanhMucSanPhamCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbDanhMucSanPhamDAL dmspDAL = new tbDanhMucSanPhamDAL();
            return dmspDAL.Get(cri.Criter, 1, number, tbDanhMucSanPhamColumns.madanhmuc.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbDanhMucSanPhamCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbDanhMucSanPhamDAL dmspDAL = new tbDanhMucSanPhamDAL();
            return dmspDAL.Get(cri.Criter, 1, number, tbDanhMucSanPhamColumns.madanhmuc.ToString(), OrderDirection.DESC.ToString(), out total);
        }

        public void Xoa(int iD)
        {
            tbDanhMucSanPhamDAL dmspDAl = new tbDanhMucSanPhamDAL();
            dmspDAl.Delete(iD);
        }
    }
}
